package com.example.mapper.mapper;

import com.example.mapper.domain.User;
import com.example.mapper.util.MyMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;
import java.util.Map;

public interface UserMapper extends MyMapper<User> {

    @SelectProvider(type=UserSqlProvider.class,method = "getList")
    List<User> getList(Map<String,Object> params);


    @Select("<script>"
            + "SELECT * FROM user"
            + "<if test='page!=null and pageSize!=null'>"
            + "LIMIT #{page},#{pageSize}"
            + "</if>"
            + "</script>")
    List<User> getAll(@Param("page") Integer page,@Param("pageSize") Integer pageSize);

    @Select("SELECT * FROM user WHERE username=#{username}")
    User login(@Param("username") String username,@Param("password") String password);

}